#include <stdio.h>
#include<stdlib.h>
#include <assert.h>

typedef struct log{

    char *path;
    int flag;
}LOG;

static LOG *_log=NULL;

LOG *getInstance(){
    if(_log!=NULL){
        printf(_log->path);
        printf("log != null return\n");
        return _log;
    }else {
        _log=(LOG*)malloc(sizeof(LOG));
        assert(_log!=NULL);
        return _log;
    }

}

int main(){

    LOG* log1=getInstance();
    log1->path="/home/";

    fprintf(stdout,"log1->path:%s\n",log1->path);
    LOG* log2=getInstance();
    log2->path="/opt/";
        fprintf(stdout,"log2->path:%s\n",log2->path) ;

    if (log1==log2){

        fprintf(stdout,"log1==log2\n");
    }

    fprintf(stdout,"log1->path:%s\n",log1->path);
    fprintf(stdout,"log2->path:%s\n",log2->path) ;

    //虽然创建了两个对象，其实都在修改一个变量，验证了单例的唯一性，第一次home。第二次把变量改成了opt，但是还是一个变量

}

